<template>
  <div>
    <el-table
      :data="friendList"
      style="width: 100%"
      max-height="400"
      stripe
    >

      <el-table-column
        prop="nickname"
        label="网名"
        width="180"
      />

      <el-table-column
        prop="id"
        label="账号"
        width="180"
      />

      <el-table-column
        prop="remark"
        label="备注"
      />

      <el-table-column
        fixed="right"
        label="操作"
        width="250"
      >
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            style="color: red"
            @click="deleteFriend(scope.row)"
          >删除好友</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

import { deleteFriend } from '@/api/bot'

export default {
  components: {

  },
  props: {
    friendList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {

    }
  },
  methods: {
    deleteFriend(user) {
      this.$confirm('此操作将永久删除该好友, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error'
      }).then(() => {
        deleteFriend(user.id).then(() => {
          this.$emit('deleteFriended')
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        }).catch(() => {
          this.$message.error('删除失败')
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
